//
//  ICMAppointmentRepairEventTableViewCell.m
//  ICrEAM
//
//  Created by Cty on 2016/11/03.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ICMAppointmentRepairEventTableViewCell.h"
#import "ICMRepairMaintenanceModel.h"
@interface ICMAppointmentRepairEventTableViewCell ()

@property (nonatomic, strong) UILabel *operateLabel;

@property (nonatomic, strong) UILabel *orderLabel;

@property (nonatomic, strong) UILabel *eventNumberLabel;

@property (nonatomic, strong) UILabel *eventNameLabel;

@property (nonatomic, strong) UILabel *workingTimeLabel;

@property (nonatomic, strong) UILabel *priceLabel;

@property (nonatomic, strong) UILabel *workingPriceLabel;

@property (nonatomic, strong) UILabel *repairTypeLabel;

@property (nonatomic, strong) UILabel *breakdownDiscribeLabel;


@end

@implementation ICMAppointmentRepairEventTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
#pragma mark    初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        UIView *repairEventCellView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth-ActualWidth(20), ActualHeight(25))];
        repairEventCellView.backgroundColor = BackgroundColor_Gray;
        [self.contentView addSubview:repairEventCellView];
        
        UILabel *operateLabel = [self createLabelWithText:@"❌" frame:CGRectMake(0, ActualHeight(5), ActualWidth(50), ActualHeight(15)) textAlignment:NSTextAlignmentCenter];
        [repairEventCellView addSubview:operateLabel];
        self.operateLabel = operateLabel;
        
        UIView *firstSep = [[UIView alloc] initWithFrame:CGRectMake(operateLabel.rightEdge, 0, 1, repairEventCellView.height)];
        firstSep.backgroundColor = BorderColor_Gray;
        [repairEventCellView addSubview:firstSep];
        
        UILabel *orderLabel = [self createLabelWithText:@"1" frame:CGRectMake(firstSep.rightEdge, operateLabel.y, ActualWidth(50), ActualHeight(15)) textAlignment:NSTextAlignmentCenter];
        [repairEventCellView addSubview:orderLabel];
        self.orderLabel = orderLabel;
        
        UIView *secondSep = [[UIView alloc] initWithFrame:CGRectMake(orderLabel.rightEdge, 0, 1, repairEventCellView.height)];
        secondSep.backgroundColor = BorderColor_Gray;
        [repairEventCellView addSubview:secondSep];
        
        UILabel *eventNumberLabel = [self createLabelWithText:@"" frame:CGRectMake(secondSep.rightEdge, operateLabel.y, ActualWidth(145), ActualHeight(15)) textAlignment:NSTextAlignmentCenter];
        [repairEventCellView addSubview:eventNumberLabel];
        self.eventNumberLabel = eventNumberLabel;
        
        UIView *thirdSep = [[UIView alloc] initWithFrame:CGRectMake(eventNumberLabel.rightEdge, 0, 1, repairEventCellView.height)];
        thirdSep.backgroundColor = BorderColor_Gray;
        [repairEventCellView addSubview:thirdSep];
        
        UILabel *eventNameLabel = [self createLabelWithText:@"" frame:CGRectMake(thirdSep.rightEdge, operateLabel.y, ActualWidth(235), ActualHeight(15)) textAlignment:NSTextAlignmentLeft];
        [repairEventCellView addSubview:eventNameLabel];
        self.eventNameLabel = eventNameLabel;
        
        UIView *fourthSep = [[UIView alloc] initWithFrame:CGRectMake(eventNameLabel.rightEdge, 0, 1, repairEventCellView.height)];
        fourthSep.backgroundColor = BorderColor_Gray;
        [repairEventCellView addSubview:fourthSep];
        
        UILabel *workingTimeLabel = [self createLabelWithText:@"" frame:CGRectMake(fourthSep.rightEdge, operateLabel.y, ActualWidth(75), ActualHeight(15)) textAlignment:NSTextAlignmentRight];
        [repairEventCellView addSubview:workingTimeLabel];
        self.workingTimeLabel = workingTimeLabel;
        
        UIView *fifthSep = [[UIView alloc] initWithFrame:CGRectMake(workingTimeLabel.rightEdge, 0, 1, repairEventCellView.height)];
        fifthSep.backgroundColor = BorderColor_Gray;
        [repairEventCellView addSubview:fifthSep];
        
        UILabel *priceLabel = [self createLabelWithText:@"" frame:CGRectMake(fifthSep.rightEdge, operateLabel.y, ActualWidth(75), ActualHeight(15)) textAlignment:NSTextAlignmentRight];
        [repairEventCellView addSubview:priceLabel];
        self.priceLabel = priceLabel;
        
        UIView *addSep = [[UIView alloc] initWithFrame:CGRectMake(priceLabel.rightEdge, 0, 1, repairEventCellView.height)];
        addSep.backgroundColor = BorderColor_Gray;
        [repairEventCellView addSubview:addSep];
        
        UILabel *workingPriceLabel = [self createLabelWithText:@"" frame:CGRectMake(addSep.rightEdge, operateLabel.y, ActualWidth(150), ActualHeight(15)) textAlignment:NSTextAlignmentRight];
        [repairEventCellView addSubview:workingPriceLabel];
        self.workingPriceLabel = workingPriceLabel;
        
        UIView *sixthSep = [[UIView alloc] initWithFrame:CGRectMake(workingPriceLabel.rightEdge, 0, 1, repairEventCellView.height)];
        sixthSep.backgroundColor = BorderColor_Gray;
        [repairEventCellView addSubview:sixthSep];
        
        UILabel *repairTypeLabel = [self createLabelWithText:@"" frame:CGRectMake(sixthSep.rightEdge, operateLabel.y, ActualWidth(75), ActualHeight(15)) textAlignment:NSTextAlignmentCenter];
        [repairEventCellView addSubview:repairTypeLabel];
        self.repairTypeLabel = repairTypeLabel;
        
        UIView *seventhSep = [[UIView alloc] initWithFrame:CGRectMake(repairTypeLabel.rightEdge, 0, 1, repairEventCellView.height)];
        seventhSep.backgroundColor = BorderColor_Gray;
        [repairEventCellView addSubview:seventhSep];
        
        UILabel *breakdownDiscribeLabel = [self createLabelWithText:@"" frame:CGRectMake(seventhSep.rightEdge, operateLabel.y, ScreenWidth-ActualWidth(40)-repairTypeLabel.rightEdge, ActualHeight(15)) textAlignment:NSTextAlignmentCenter];
        [repairEventCellView addSubview:breakdownDiscribeLabel];
        self.breakdownDiscribeLabel = breakdownDiscribeLabel;
    }
    return self;
}
#pragma mark    根据model设置界面
- (void)setupLabelsWithModel:(ICMRepairMaintenanceModel *)model{
//    self.eventNameLabel.text = model.eventName;
//    self.eventNumberLabel.text = model.eventNumber;
//    self.workingTimeLabel.text = model.workingTime;
//    self.workingPriceLabel.text = model.workingPrice;
//    self.repairTypeLabel.text = model.type;
//    self.breakdownDiscribeLabel.text = model.breakdownDiscribe;
    //工时单价
//    self.priceLabel.text = model.workingHoursPrice;
    
    
    
}

- (UILabel *)createLabelWithText:(NSString *)text frame:(CGRect)frame textAlignment:(NSTextAlignment)textAlignment{
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.text = text;
    label.font = ContentFont;
    label.textColor = ContentTextColor_Black;
    label.textAlignment = textAlignment;
    return label;
}
@end
